/**
 * Copyright
 */
package org.sevaapp.domain;

import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.sevaapp.dao.DaoException;
import org.sevaapp.dao.ReferralDao;
import org.springframework.beans.factory.annotation.Autowired;

/**
 *  THIS IS A CODE GENERATED FILE. DO NOT EDIT.
 */

@MappedSuperclass
public abstract class BaseReferral extends BaseDomainObject {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Integer id;
	
	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getId() {
		return id;
	}

	private Integer referralId;
	public Integer getReferralId() {
		return referralId;
	}

	public void setReferralId(Integer referralId) {
		this.referralId = referralId;
	}

	private Integer applicationId;
	public Integer getApplicationId() {
		return applicationId;
	}

	public void setApplicationId(Integer applicationId) {
		this.applicationId = applicationId;
	}

	private String patientFirstName;
	public String getPatientFirstName() {
		return patientFirstName;
	}

	public void setPatientFirstName(String patientFirstName) {
		this.patientFirstName = patientFirstName;
	}

	private String patientMiddleName;
	public String getPatientMiddleName() {
		return patientMiddleName;
	}

	public void setPatientMiddleName(String patientMiddleName) {
		this.patientMiddleName = patientMiddleName;
	}
	private String patientLastName;
	public String getPatientLastName() {
		return patientLastName;
	}

	public void setPatientLastName(String patientLastName) {
		this.patientLastName = patientLastName;
	}
	

	@OneToOne(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST, CascadeType.ALL, CascadeType.REMOVE})
	@JoinColumn(name = "APPLICANT_ID", nullable = false)
	private Applicant applicant;

	public Applicant getApplicant() {
		if (applicant == null ){
			applicant = new Applicant();
		}
		return applicant;
	}

	public void setApplicant(Applicant applicant) {
		this.applicant = applicant;
	}

	@OneToOne(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST,CascadeType.ALL})
	@JoinColumn(name = "PHYSICIAN_ID", nullable = true)
	private Physician assignedPhysician;
	public void setAssignedPhysician(Physician assignedPhysician) {
		this.assignedPhysician = assignedPhysician;
	}

	public Physician getAssignedPhysician() {
		return assignedPhysician;
	}
	
	@OneToOne(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST,CascadeType.ALL})
	@JoinColumn(name = "LAB_ID", nullable = true)
	private Lab assignedLab;
	public void setAssignedLab(Lab assignedLab) {
		this.assignedLab = assignedLab;
	}

	public Lab getAssignedLab() {
		return assignedLab;
	}

	private boolean newReferral;
	public boolean isNewReferral() {
		return newReferral;
	}

	public void setNewReferral(boolean newReferral) {
		this.newReferral = newReferral;
	}

	private String purposeOfVisit;
	public String getPurposeOfVisit() {
		if ( purposeOfVisit == null )
			purposeOfVisit = "Physician Consultation";
		return purposeOfVisit;
	}

	public void setPurposeOfVisit(String purposeOfVisit) {
		this.purposeOfVisit = purposeOfVisit;
	}

	private String descOfPurpose;
	public String getDescOfPurpose() {
		return descOfPurpose;
	}

	public void setDescOfPurpose(String descOfPurpose) {
		this.descOfPurpose = descOfPurpose;
	}

	private int existingReferralId;
	
	public int getExistingReferralId() {
		return existingReferralId;
	}

	public void setExistingReferralId(int existingReferralId) {
		this.existingReferralId = existingReferralId;
	}

	private String prescribedTests;
	public String getPrescribedTests() {
		return prescribedTests;
	}

	public void setPrescribedTests(String prescribedTests) {
		this.prescribedTests = prescribedTests;
	}

	private String physicianName;
	public String getPhysicianName() {
		return physicianName;
	}

	public void setPhysicianName(String physicianName) {
		this.physicianName = physicianName;
	}

	private String physicianSpeciality;
	public String getPhysicianSpeciality() {
		return physicianSpeciality;
	}

	public void setPhysicianSpeciality(String physicianSpeciality) {
		this.physicianSpeciality = physicianSpeciality;
	}

	private String applicantSign1;

	public String getApplicantSign1() {
		return applicantSign1;
	}

	public void setApplicantSign1(String applicantSign1) {
		this.applicantSign1 = applicantSign1;
	}

	private String applicantSign2;

	public String getApplicantSign2() {
		return applicantSign2;
	}

	public void setApplicantSign2(String applicantSign2) {
		this.applicantSign2 = applicantSign2;
	}
	
	private String physicianPhNo;
	public String getPhysicianPhNo() {
		return physicianPhNo;
	}

	public void setPhysicianPhNo(String physicianPhNo) {
		this.physicianPhNo = physicianPhNo;
	}

	private String donationPledge;

	
	public String getDonationPledge() {
		return donationPledge;
	}

	public void setDonationPledge(String donationPledge) {
		this.donationPledge = donationPledge;
	}

    private String applicationStatus;
	
	public String getApplicationStatus() {
		return applicationStatus;
	}

	public void setApplicationStatus(String applicationStatus) {
		this.applicationStatus = applicationStatus;
	}

	private String serviceType;
	
	public String getServiceType() {
		return serviceType;
	}

	public void setServiceType(String serviceType) {
		this.serviceType = serviceType;
	}

	private String evaluatorName;
	
	public void setEvaluatorName(String evaluatorName) {
		this.evaluatorName = evaluatorName;
	}

	public String getEvaluatorName() {
		return evaluatorName;
	}

	private String comments;
	
	public void setComments(String comments) {
		this.comments = comments;
	}

	public String getComments() {
		return comments;
	}

	@Temporal(TemporalType.DATE)
	private java.util.Date evaluationDate;
	
	public void setEvaluationDate(java.util.Date evaluationDate) {
		this.evaluationDate = evaluationDate;
	}

	public java.util.Date getEvaluationDate() {
		return evaluationDate;
	}
	
	@Temporal(TemporalType.DATE)
	private java.util.Date creationDate;
	public void setCreationDate(java.util.Date creationDate) {
		this.creationDate = creationDate;
	}

	public java.util.Date getCreationDate() {
		return creationDate;
	}
	
	@Temporal(TemporalType.DATE)
	private java.util.Date signDate;
	public void setSignDate(java.util.Date signDate) {
		this.signDate = signDate;
	}

	public java.util.Date getSignDate() {
		return signDate;
	}
	
	@Autowired
	@Transient
	private ReferralDao dao;

	// CRUD Methods
	public void add() {
		try {
			dao.add((Referral) this);
		} catch (DaoException ex) {
			ex.printStackTrace();
		}
	}

	public void add(Referral referralData) {
		try {
			dao.add((Referral) referralData);
		} catch (DaoException ex) {
			ex.printStackTrace();
		}
	}

	public void delete(Integer id) {
		try {
			dao.delete(id);
		} catch (DaoException ex) {
			ex.printStackTrace();
		}
	}

	public void update(Referral domainObject) {
		try {
			dao.update(domainObject);
		} catch (DaoException ex) {
			ex.printStackTrace();
		}
	}

	public Referral load(Integer id) {
		Referral newDomainObj = null;
		try {
			newDomainObj = dao.load(id);
		} catch (DaoException ex) {
			ex.printStackTrace();
		}
		return newDomainObj;
	}

}
